<template>
  <el-dialog title="添加二级分类"
             :visible.sync="visible"
             @close="handleCancelCreate">
    <el-form :model="createTemp" label-position="top">
      <!--<el-form-item label="发布时间" prop="">-->
        <!--&lt;!&ndash;<el-input v-model="updateTemp.publishedAt" type="text">&ndash;&gt;-->
        <!--&lt;!&ndash;</el-input>&ndash;&gt;-->
        <!--<el-date-picker-->
          <!--v-model="createTemp.publishedAt"-->
          <!--type="datetime"-->
          <!--format="yyyy-MM-dd HH:mm"-->
          <!--placeholder="选择日期时间">-->
        <!--</el-date-picker>-->
      <!--</el-form-item>-->
      <p>所属一级分类</p>
      <el-select v-model="parentId" placeholder="请选择所属一级分类">
        <el-option
          v-for="item in mainCategory"
          :key="item.index"
          :label="item.name"
          :value="item.id">
        </el-option>
      </el-select>
      <el-form-item label="类别名称" prop="">
        <el-input v-model="createTemp.name" type="text" placeholder="请输入类别名称">
        </el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="handleCancelCreate">取消</el-button>
      <el-button type="primary" @click="handleCreateData">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
  // import Tinymce from '@/components/Tinymce'

  export default {
    name: 'create-dialog',
    components: {
      // Tinymce
    },
    data() {
      return {
        img: null,
        visible: false,
        imgUrl: '',
        dialogVisible: false,
        parentId: '2222'
      }
    },
    created() {
      console.log(this.mainCategory)
    },
    props: {
      createTemp: Object,
      mainCategory: Array,
      dialogCreateFormVisible: Boolean
    },
    watch: {
      dialogCreateFormVisible(val) {
        this.visible = val
      }
    },
    methods: {
      handleCancelCreate() {
        this.visible = false
        this.$emit('cancel', this.visible)
      },
      handleCreateData() {
          this.createTemp.parent_id = this.parentId
        console.log(this.createTemp.parent_id)
          this.$emit('create')
      }
    }
  }
</script>

<style scoped>

</style>
